const express = require('express')
const app = express()

app.use(express.json())


app.listen(8080,function( ) {
    console.log('-----------server started at port 80')
})

//商品列表数据
let goodsList = require('./goods')

app.get('/goods/list' ,function(req ,res) {
    let { page ,size ,name} = req.query
    let arr = goodsList
    if(!!name) {
        arr = goodsList.filter( item => item.title.includes(name))
    }

    res.send({code:200,data:arr.slice((page - 1)* size,page * size)})
})